<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员控制台 - LAgain</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #f5f7fa;
            min-height: 100vh;
        }
        
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px 0;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        
        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo h1 {
            font-size: 24px;
            font-weight: 700;
        }
        
        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }
        
        .logout-btn {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .logout-btn:hover {
            background: rgba(255, 255, 255, 0.3);
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 30px 20px;
        }
        
        .welcome-card {
            background: white;
            border-radius: 12px;
            padding: 30px;
            margin-bottom: 30px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }
        
        .welcome-card h2 {
            color: #333;
            margin-bottom: 10px;
            font-size: 28px;
        }
        
        .welcome-card p {
            color: #666;
            font-size: 16px;
            line-height: 1.6;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .stat-card {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            transition: transform 0.3s ease;
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
        }
        
        .stat-icon {
            width: 50px;
            height: 50px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            margin-bottom: 15px;
        }
        
        .stat-icon.users {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
        }
        
        .stat-icon.logs {
            background: linear-gradient(135deg, #f093fb, #f5576c);
            color: white;
        }
        
        .stat-icon.system {
            background: linear-gradient(135deg, #4facfe, #00f2fe);
            color: white;
        }
        
        .stat-number {
            font-size: 32px;
            font-weight: bold;
            color: #333;
            margin-bottom: 5px;
        }
        
        .stat-label {
            color: #666;
            font-size: 14px;
        }
        
        .actions-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }
        
        .action-card {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }
        
        .action-card h3 {
            color: #333;
            margin-bottom: 15px;
            font-size: 18px;
        }
        
        .action-btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-bottom: 10px;
        }
        
        .action-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
        }
        
        .action-btn.secondary {
            background: #f8f9fa;
            color: #333;
            border: 1px solid #e9ecef;
        }
        
        .action-btn.secondary:hover {
            background: #e9ecef;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }
        
        .alert {
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            font-size: 14px;
            display: none;
        }
        
        .alert.success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        
        .alert.error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        
        .alert.info {
            background: #d1ecf1;
            color: #0c5460;
            border: 1px solid #bee5eb;
        }
        
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                gap: 15px;
                text-align: center;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
            
            .actions-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="header-content">
            <div class="logo">
                <h1>LAgain 管理员控制台</h1>
            </div>
            <div class="user-info">
                <div class="user-avatar" id="userAvatar">管</div>
                <div>
                    <div id="userName">管理员</div>
                    <div style="font-size: 12px; opacity: 0.8;">Administrator</div>
                </div>
                <button class="logout-btn" onclick="logout()">退出登录</button>
            </div>
        </div>
    </div>
    
    <div class="container">
        <div id="alert" class="alert"></div>
        
        <div class="welcome-card">
            <h2>欢迎回来！</h2>
            <p>您正在使用管理员权限访问 LAgain 系统。在这里您可以管理用户、查看系统日志、配置系统设置等。</p>
        </div>
        
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-icon users">👥</div>
                <div class="stat-number" id="userCount">-</div>
                <div class="stat-label">注册用户</div>
            </div>
            
            <div class="stat-card">
                <div class="stat-icon logs">📊</div>
                <div class="stat-number" id="logCount">-</div>
                <div class="stat-label">访问日志</div>
            </div>
            
            <div class="stat-card">
                <div class="stat-icon system">⚙️</div>
                <div class="stat-number">正常</div>
                <div class="stat-label">系统状态</div>
            </div>
        </div>
        
        <div class="actions-grid">
            <div class="action-card">
                <h3>用户管理</h3>
                <button class="action-btn" onclick="viewUsers()">查看所有用户</button>
                <button class="action-btn secondary" onclick="manageRoles()">角色权限管理</button>
            </div>
            
            <div class="action-card">
                <h3>系统监控</h3>
                <button class="action-btn" onclick="viewLogs()">查看访问日志</button>
                <button class="action-btn secondary" onclick="viewSystemInfo()">系统信息</button>
            </div>
            
            <div class="action-card">
                <h3>数据管理</h3>
                <button class="action-btn" onclick="backupData()">数据备份</button>
                <button class="action-btn secondary" onclick="exportData()">数据导出</button>
            </div>
            
            <div class="action-card">
                <h3>系统设置</h3>
                <button class="action-btn" onclick="systemSettings()">系统配置</button>
                <button class="action-btn secondary" onclick="securitySettings()">安全设置</button>
            </div>
        </div>
    </div>
    
    <script>
        // 检查登录状态和权限
        function checkAuth() {
            const token = localStorage.getItem('token');
            const role = localStorage.getItem('role');
            
            if (!token || role !== 'ADMIN') {
                window.location.href = '/login.html';
                return false;
            }
            
            return true;
        }
        
        // 显示提示信息
        function showAlert(message, type = 'info') {
            const alert = document.getElementById('alert');
            alert.textContent = message;
            alert.className = `alert ${type}`;
            alert.style.display = 'block';
            
            setTimeout(() => {
                alert.style.display = 'none';
            }, 3000);
        }
        
        // 退出登录
        function logout() {
            if (confirm('确定要退出登录吗？')) {
                localStorage.removeItem('token');
                localStorage.removeItem('user');
                localStorage.removeItem('role');
                localStorage.removeItem('roleName');
                window.location.href = '/login.html';
            }
        }
        
        // 加载用户信息
        function loadUserInfo() {
            const user = JSON.parse(localStorage.getItem('user') || '{}');
            const roleName = localStorage.getItem('roleName');
            
            if (user.nickname) {
                document.getElementById('userName').textContent = user.nickname;
                document.getElementById('userAvatar').textContent = user.nickname.charAt(0);
            }
        }
        
        // 加载统计数据
        async function loadStats() {
            try {
                const token = localStorage.getItem('token');
                
                // 这里可以调用实际的API获取统计数据
                // 暂时使用模拟数据
                document.getElementById('userCount').textContent = '156';
                document.getElementById('logCount').textContent = '2,847';
                
            } catch (error) {
                console.error('加载统计数据失败:', error);
            }
        }
        
        // 功能按钮事件
        function viewUsers() {
            showAlert('用户管理功能开发中...', 'info');
        }
        
        function manageRoles() {
            showAlert('角色权限管理功能开发中...', 'info');
        }
        
        function viewLogs() {
            showAlert('访问日志功能开发中...', 'info');
        }
        
        function viewSystemInfo() {
            showAlert('系统信息功能开发中...', 'info');
        }
        
        function backupData() {
            if (confirm('确定要进行数据备份吗？')) {
                showAlert('数据备份已开始，请稍候...', 'success');
            }
        }
        
        function exportData() {
            showAlert('数据导出功能开发中...', 'info');
        }
        
        function systemSettings() {
            showAlert('系统配置功能开发中...', 'info');
        }
        
        function securitySettings() {
            showAlert('安全设置功能开发中...', 'info');
        }
        
        // 页面加载时执行
        window.addEventListener('load', function() {
            if (checkAuth()) {
                loadUserInfo();
                loadStats();
            }
        });
    </script>
</body>
</html>